<?php

namespace app\common\model;

use think\Model;

class Category extends Model
{
    /** 列表
     * @param $where array
     * @param $page int
     * @param $num int
     * @param $field string
     * @return object
     */
    public static function dataList($where,$page,$num,$field="*",$order="id asc"){
        return self::where($where)
            ->field($field)
            ->page($page,$num)
            ->order($order)
            ->select();
    }

    /** 列表总数统计
     * @param $where array
     * @return int
     */
    public static function dataCount($where){
        return intval(self::where($where)->count());
    }


    public static function dataListAll($where,$field ="*",$order = "id asc"){
        return self::where($where)->field($field)->order($order)->select();
    }

    /** 详情
     * @param $where array
     * @return object
     */
    public static function dataInfo($where){
        return self::where($where)->find();
    }


    /** 新增
     * @param $data array
     * @return int
     */
    public static function addInfo($data){
        return self::create($data);
    }

    /** 修改
     * @param $data array
     * @return bool
     */
    public static function editInfo($where,$data){
        return self::where($where)->update($data);
    }
}